package ufc.sd.dao;

import java.util.List;

import me.prettyprint.cassandra.serializers.LongSerializer;
import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.hector.api.Keyspace;
import me.prettyprint.hector.api.exceptions.HectorException;

public abstract class CassandraDAO<Entity> {

	public static final String KS_UNIVERSIDADE = DatabaseUtil.KS_UNIVERSIDADE;
	protected static final StringSerializer stringSerializer = StringSerializer
			.get();
	protected static final LongSerializer longSerializer = LongSerializer.get();
	protected Keyspace keyspace;

	protected CassandraDAO() {
		DatabaseUtil.initDatabase(false);
		keyspace = DatabaseUtil.getKeyspace();
	}

	public void insertAll(List<Entity> entities) throws HectorException {
		for (Entity entity : entities) {
			insert(entity);
		}
	}

	public abstract void insert(Entity entity) throws HectorException;

	public abstract List<Entity> getAll() throws HectorException;

	public abstract Entity getByKey(String key) throws HectorException;

	public abstract void delete(Entity entity);

}
